{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Wasted investment\n",
    "\n",
    "###  China's `$6.8`-trillion hole? "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "_(Data Sources: National Bureau of Statistics; The Economist)_\n",
    "\n",
    "<!-- TEASER_END-->"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "dficor = pd.read_excel('china-1979-2013-icor.xlsx','Sheet1')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "HAS CHINA really blown `$6.8` trillion on [worthless investments](http://wallstreetcn.com/node/211297) over the past five years? This is the startling claim made by two Chinese government researchers that has, understandably, [caused quite](http://www.reuters.com/article/2014/11/20/china-economy-investment-idUSL3N0TA2KP20141120) [a stir](http://www.ft.com/intl/cms/s/0/002a1978-7629-11e4-9761-00144feabdc0.html?siteedition=intl#axzz3KJdiuSo5). If true, it would mean that fully 37% of Chinese investment since 2009 was wasted on building bridges to nowhere and homes with no one in them. There is, without question, plenty of worrying evidence that Chinese investment has become less efficient in recent years. But a closer look at how the researchers produced the `$6.8` trillion figure badly damages their claim. Calling it a back-of-the-envelope estimate would be undeserved praise."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `$6.8` trillion calculation was made by Xu Ce of the National Development and Reform Commission, an economic planning agency, and Wang Yuan of the Academy of Macroeconomic Research, a think-tank under the commission. Their analysis was published last week as an [opinion piece](http://money.163.com/14/1120/02/ABF8SCQQ00253B0H.html) in the Shanghai Securities Journal, a government-run newspaper. In their article, they estimate that worthless investment totalled 7.9 trillion yuan in 2009; 5.4 trillion yuan in 2010; 4.7 trillion yuan in 2011; 10.6 trillion yuan in 2012; and 13.2 trillion yuan last year. That amounts to 41.8 trillion yuan over the past five years, or `$6.8` trillion at the current exchange rate."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Investment(￥)</th>\n",
       "      <th>Added GDP(￥)</th>\n",
       "      <th>ICOR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013</th>\n",
       "      <td> 28036</td>\n",
       "      <td> 5727</td>\n",
       "      <td> 4.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012</th>\n",
       "      <td> 25277</td>\n",
       "      <td> 5678</td>\n",
       "      <td> 4.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011</th>\n",
       "      <td> 22834</td>\n",
       "      <td> 6980</td>\n",
       "      <td> 3.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td> 19360</td>\n",
       "      <td> 5404</td>\n",
       "      <td> 3.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td> 16446</td>\n",
       "      <td> 3280</td>\n",
       "      <td> 5.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008</th>\n",
       "      <td> 13833</td>\n",
       "      <td> 4938</td>\n",
       "      <td> 2.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007</th>\n",
       "      <td> 11094</td>\n",
       "      <td> 4389</td>\n",
       "      <td> 2.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006</th>\n",
       "      <td>  9295</td>\n",
       "      <td> 3529</td>\n",
       "      <td> 2.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005</th>\n",
       "      <td>  7786</td>\n",
       "      <td> 2647</td>\n",
       "      <td> 2.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2004</th>\n",
       "      <td>  6917</td>\n",
       "      <td> 2434</td>\n",
       "      <td> 2.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003</th>\n",
       "      <td>  5596</td>\n",
       "      <td> 1614</td>\n",
       "      <td> 3.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2002</th>\n",
       "      <td>  4557</td>\n",
       "      <td> 1145</td>\n",
       "      <td> 3.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001</th>\n",
       "      <td>  3977</td>\n",
       "      <td> 1028</td>\n",
       "      <td> 3.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000</th>\n",
       "      <td>  3484</td>\n",
       "      <td>  762</td>\n",
       "      <td> 4.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999</th>\n",
       "      <td>  3295</td>\n",
       "      <td>  459</td>\n",
       "      <td> 7.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1998</th>\n",
       "      <td>  3131</td>\n",
       "      <td>  487</td>\n",
       "      <td> 6.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1997</th>\n",
       "      <td>  2997</td>\n",
       "      <td>  749</td>\n",
       "      <td> 4.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1996</th>\n",
       "      <td>  2878</td>\n",
       "      <td> 1095</td>\n",
       "      <td> 2.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995</th>\n",
       "      <td>  2547</td>\n",
       "      <td> 1300</td>\n",
       "      <td> 1.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1994</th>\n",
       "      <td>  2034</td>\n",
       "      <td> 1328</td>\n",
       "      <td> 1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1993</th>\n",
       "      <td>  1572</td>\n",
       "      <td>  937</td>\n",
       "      <td> 1.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1992</th>\n",
       "      <td>  1009</td>\n",
       "      <td>  499</td>\n",
       "      <td> 2.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991</th>\n",
       "      <td>   787</td>\n",
       "      <td>  323</td>\n",
       "      <td> 2.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990</th>\n",
       "      <td>   675</td>\n",
       "      <td>  204</td>\n",
       "      <td> 3.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1989</th>\n",
       "      <td>   633</td>\n",
       "      <td>  192</td>\n",
       "      <td> 3.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1988</th>\n",
       "      <td>   570</td>\n",
       "      <td>  311</td>\n",
       "      <td> 1.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1987</th>\n",
       "      <td>   446</td>\n",
       "      <td>  177</td>\n",
       "      <td> 2.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1986</th>\n",
       "      <td>   394</td>\n",
       "      <td>  143</td>\n",
       "      <td> 2.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1985</th>\n",
       "      <td>   346</td>\n",
       "      <td>  171</td>\n",
       "      <td> 2.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1984</th>\n",
       "      <td>   252</td>\n",
       "      <td>  115</td>\n",
       "      <td> 2.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1983</th>\n",
       "      <td>   204</td>\n",
       "      <td>   63</td>\n",
       "      <td> 3.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1982</th>\n",
       "      <td>   178</td>\n",
       "      <td>   58</td>\n",
       "      <td> 3.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1981</th>\n",
       "      <td>   163</td>\n",
       "      <td>   42</td>\n",
       "      <td> 3.92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1980</th>\n",
       "      <td>   160</td>\n",
       "      <td>   50</td>\n",
       "      <td> 3.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1979</th>\n",
       "      <td>   148</td>\n",
       "      <td>   49</td>\n",
       "      <td> 3.04</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Investment(￥)  Added GDP(￥)  ICOR\n",
       "2013          28036          5727  4.90\n",
       "2012          25277          5678  4.45\n",
       "2011          22834          6980  3.27\n",
       "2010          19360          5404  3.58\n",
       "2009          16446          3280  5.01\n",
       "2008          13833          4938  2.80\n",
       "2007          11094          4389  2.53\n",
       "2006           9295          3529  2.63\n",
       "2005           7786          2647  2.94\n",
       "2004           6917          2434  2.84\n",
       "2003           5596          1614  3.47\n",
       "2002           4557          1145  3.98\n",
       "2001           3977          1028  3.87\n",
       "2000           3484           762  4.57\n",
       "1999           3295           459  7.17\n",
       "1998           3131           487  6.43\n",
       "1997           2997           749  4.00\n",
       "1996           2878          1095  2.63\n",
       "1995           2547          1300  1.96\n",
       "1994           2034          1328  1.53\n",
       "1993           1572           937  1.68\n",
       "1992           1009           499  2.02\n",
       "1991            787           323  2.44\n",
       "1990            675           204  3.31\n",
       "1989            633           192  3.29\n",
       "1988            570           311  1.83\n",
       "1987            446           177  2.52\n",
       "1986            394           143  2.75\n",
       "1985            346           171  2.02\n",
       "1984            252           115  2.19\n",
       "1983            204            63  3.26\n",
       "1982            178            58  3.07\n",
       "1981            163            42  3.92\n",
       "1980            160            50  3.20\n",
       "1979            148            49  3.04"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dficor"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These are remarkably precise figures for wasted investment, something that, by its nature, is extremely hard to pin down. There are practical difficulties – for example, we know that some government investment funds have been skimmed off by corrupt officials, but it takes careful forensics to track the ill-gotten gains of one rotten official, let alone thousands of them. Even greater are the theoretical challenges. China has clearly built too many homes, too quickly, but if some of those that stand empty today are eventually bought then what once seemed a wasted investment could yet turn into a productive one."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So how exactly do Mr Xu and Ms Wang arrive at their numbers? Their method is to compare China’s capital efficiency in the 1980s and 1990s with the past decade; they treat any decline in efficiency as evidence of wasted investment. Although they don’t publish their calculations in full, their conclusions have the virtue of being very easy to replicate from official data. (Be warned that this is slightly wonky.)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Mr Xu and Ms Wang base their analysis entirely on the concept of [incremental capital output ratio, or ICOR](http://www.investopedia.com/terms/i/icor.asp). ICOR is a measure of how much investment it takes to produce each additional unit of growth in an economy, with investment the numerator and additional GDP the denominator. The higher a country’s ICOR, the less efficient it is – that is, it takes more investment to produce a smaller amount of economic output. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$ICOR = \\frac {Annual\\ Investment} {Annual\\ Added\\ GDP} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 计算指定时间段begin,end的ICOR均值\n",
    "def icor_average(begin,end):\n",
    "    icor = dficor.loc[end:begin]\n",
    "    icor.loc['{1}_{0}_Average'.format(begin,end),'ICOR'] = round(icor.loc[:,'ICOR'].mean(),2)\n",
    "    return icor"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Mr Xu and Ms Wang begin by calculating that China’s average ICOR from 1979 to 1996 was 2.6. To do so they tot up each year’s ICOR and calculate a simple average. Here is a table of all of China's ICORs from 1979 to 1996, yielding the same average that they calculate:  \n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Investment(￥)</th>\n",
       "      <th>Added GDP(￥)</th>\n",
       "      <th>ICOR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1996</th>\n",
       "      <td> 2878</td>\n",
       "      <td> 1095</td>\n",
       "      <td> 2.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1995</th>\n",
       "      <td> 2547</td>\n",
       "      <td> 1300</td>\n",
       "      <td> 1.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1994</th>\n",
       "      <td> 2034</td>\n",
       "      <td> 1328</td>\n",
       "      <td> 1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1993</th>\n",
       "      <td> 1572</td>\n",
       "      <td>  937</td>\n",
       "      <td> 1.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1992</th>\n",
       "      <td> 1009</td>\n",
       "      <td>  499</td>\n",
       "      <td> 2.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1991</th>\n",
       "      <td>  787</td>\n",
       "      <td>  323</td>\n",
       "      <td> 2.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1990</th>\n",
       "      <td>  675</td>\n",
       "      <td>  204</td>\n",
       "      <td> 3.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1989</th>\n",
       "      <td>  633</td>\n",
       "      <td>  192</td>\n",
       "      <td> 3.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1988</th>\n",
       "      <td>  570</td>\n",
       "      <td>  311</td>\n",
       "      <td> 1.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1987</th>\n",
       "      <td>  446</td>\n",
       "      <td>  177</td>\n",
       "      <td> 2.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1986</th>\n",
       "      <td>  394</td>\n",
       "      <td>  143</td>\n",
       "      <td> 2.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1985</th>\n",
       "      <td>  346</td>\n",
       "      <td>  171</td>\n",
       "      <td> 2.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1984</th>\n",
       "      <td>  252</td>\n",
       "      <td>  115</td>\n",
       "      <td> 2.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1983</th>\n",
       "      <td>  204</td>\n",
       "      <td>   63</td>\n",
       "      <td> 3.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1982</th>\n",
       "      <td>  178</td>\n",
       "      <td>   58</td>\n",
       "      <td> 3.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1981</th>\n",
       "      <td>  163</td>\n",
       "      <td>   42</td>\n",
       "      <td> 3.92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1980</th>\n",
       "      <td>  160</td>\n",
       "      <td>   50</td>\n",
       "      <td> 3.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1979</th>\n",
       "      <td>  148</td>\n",
       "      <td>   49</td>\n",
       "      <td> 3.04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1996_1979_Average</th>\n",
       "      <td>  NaN</td>\n",
       "      <td>  NaN</td>\n",
       "      <td> 2.59</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Investment(￥)  Added GDP(￥)  ICOR\n",
       "1996                        2878          1095  2.63\n",
       "1995                        2547          1300  1.96\n",
       "1994                        2034          1328  1.53\n",
       "1993                        1572           937  1.68\n",
       "1992                        1009           499  2.02\n",
       "1991                         787           323  2.44\n",
       "1990                         675           204  3.31\n",
       "1989                         633           192  3.29\n",
       "1988                         570           311  1.83\n",
       "1987                         446           177  2.52\n",
       "1986                         394           143  2.75\n",
       "1985                         346           171  2.02\n",
       "1984                         252           115  2.19\n",
       "1983                         204            63  3.26\n",
       "1982                         178            58  3.07\n",
       "1981                         163            42  3.92\n",
       "1980                         160            50  3.20\n",
       "1979                         148            49  3.04\n",
       "1996_1979_Average            NaN           NaN  2.59"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "icor_average(1979,1996)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For the next step, they calculate the ICORs from 1997 to 2013. Here is the table for that. As in Mr Xu and Ms Wang’s article, the average ICOR is 4.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Investment(￥)</th>\n",
       "      <th>Added GDP(￥)</th>\n",
       "      <th>ICOR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013</th>\n",
       "      <td> 28036</td>\n",
       "      <td> 5727</td>\n",
       "      <td> 4.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012</th>\n",
       "      <td> 25277</td>\n",
       "      <td> 5678</td>\n",
       "      <td> 4.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011</th>\n",
       "      <td> 22834</td>\n",
       "      <td> 6980</td>\n",
       "      <td> 3.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td> 19360</td>\n",
       "      <td> 5404</td>\n",
       "      <td> 3.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td> 16446</td>\n",
       "      <td> 3280</td>\n",
       "      <td> 5.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008</th>\n",
       "      <td> 13833</td>\n",
       "      <td> 4938</td>\n",
       "      <td> 2.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007</th>\n",
       "      <td> 11094</td>\n",
       "      <td> 4389</td>\n",
       "      <td> 2.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006</th>\n",
       "      <td>  9295</td>\n",
       "      <td> 3529</td>\n",
       "      <td> 2.63</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005</th>\n",
       "      <td>  7786</td>\n",
       "      <td> 2647</td>\n",
       "      <td> 2.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2004</th>\n",
       "      <td>  6917</td>\n",
       "      <td> 2434</td>\n",
       "      <td> 2.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003</th>\n",
       "      <td>  5596</td>\n",
       "      <td> 1614</td>\n",
       "      <td> 3.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2002</th>\n",
       "      <td>  4557</td>\n",
       "      <td> 1145</td>\n",
       "      <td> 3.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2001</th>\n",
       "      <td>  3977</td>\n",
       "      <td> 1028</td>\n",
       "      <td> 3.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000</th>\n",
       "      <td>  3484</td>\n",
       "      <td>  762</td>\n",
       "      <td> 4.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999</th>\n",
       "      <td>  3295</td>\n",
       "      <td>  459</td>\n",
       "      <td> 7.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1998</th>\n",
       "      <td>  3131</td>\n",
       "      <td>  487</td>\n",
       "      <td> 6.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1997</th>\n",
       "      <td>  2997</td>\n",
       "      <td>  749</td>\n",
       "      <td> 4.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013_1997_Average</th>\n",
       "      <td>   NaN</td>\n",
       "      <td>  NaN</td>\n",
       "      <td> 4.03</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Investment(￥)  Added GDP(￥)  ICOR\n",
       "2013                       28036          5727  4.90\n",
       "2012                       25277          5678  4.45\n",
       "2011                       22834          6980  3.27\n",
       "2010                       19360          5404  3.58\n",
       "2009                       16446          3280  5.01\n",
       "2008                       13833          4938  2.80\n",
       "2007                       11094          4389  2.53\n",
       "2006                        9295          3529  2.63\n",
       "2005                        7786          2647  2.94\n",
       "2004                        6917          2434  2.84\n",
       "2003                        5596          1614  3.47\n",
       "2002                        4557          1145  3.98\n",
       "2001                        3977          1028  3.87\n",
       "2000                        3484           762  4.57\n",
       "1999                        3295           459  7.17\n",
       "1998                        3131           487  6.43\n",
       "1997                        2997           749  4.00\n",
       "2013_1997_Average            NaN           NaN  4.03"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "icor_average(1997,2013)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These numbers are fine for what they are – estimates of the efficiency of Chinese investment – but it is at this point that the two researchers make several unreasonable leaps of logic. First, they use the 1979-96 ICOR average of 2.6 as their baseline estimate of what China’s ICOR ought to be were its investments all efficient. Next, they calculate the difference in China’s investment efficiency from 2009-13. For example, in 2009, the ICOR was 5, which is 48% less efficient than the baseline ICOR of 2.6. Therefore, they conclude, 48% of all Chinese investment in 2009 – 7.9 trillion yuan – was worthless. Similar calculations for each year up until 2013 yields the eye-popping result that 41.8 trillion yuan has been wasted."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$ Efficiency\\ of\\ Investment = \\frac {1979-96\\ ICOR\\ average\\ as\\ baseline\\ ICOR} {China’s\\ investment\\ efficiency\\ from\\ 2009-13}*100\\% $$\n",
    "\n",
    "$$ Worthless\\ Investment = Investment*(1 - Efficiency\\ of\\ Investment) $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def worthlessInvt(begin,end,baselineICOR):\n",
    "    WorthlessInvt = dficor.loc[end:begin]\n",
    "    WorthlessInvt['WorthlessInvt pct'] = WorthlessInvt.loc[:,'ICOR'].apply(lambda x: 1-baselineICOR/x)\n",
    "    WorthlessInvt['WorthlessInvt'] = WorthlessInvt.loc[:,u'Investment(￥)'] * WorthlessInvt.loc[:,'WorthlessInvt pct']\n",
    "    WorthlessInvt.loc['{1}_{0}_Total'.format(begin,end),'WorthlessInvt'] = WorthlessInvt.loc[:,'WorthlessInvt'].sum()\n",
    "    return WorthlessInvt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Investment(￥)</th>\n",
       "      <th>Added GDP(￥)</th>\n",
       "      <th>ICOR</th>\n",
       "      <th>WorthlessInvt pct</th>\n",
       "      <th>WorthlessInvt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013</th>\n",
       "      <td> 28036</td>\n",
       "      <td> 5727</td>\n",
       "      <td> 4.90</td>\n",
       "      <td> 0.471429</td>\n",
       "      <td> 13216.971429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012</th>\n",
       "      <td> 25277</td>\n",
       "      <td> 5678</td>\n",
       "      <td> 4.45</td>\n",
       "      <td> 0.417978</td>\n",
       "      <td> 10565.217978</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011</th>\n",
       "      <td> 22834</td>\n",
       "      <td> 6980</td>\n",
       "      <td> 3.27</td>\n",
       "      <td> 0.207951</td>\n",
       "      <td>  4748.354740</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td> 19360</td>\n",
       "      <td> 5404</td>\n",
       "      <td> 3.58</td>\n",
       "      <td> 0.276536</td>\n",
       "      <td>  5353.743017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td> 16446</td>\n",
       "      <td> 3280</td>\n",
       "      <td> 5.01</td>\n",
       "      <td> 0.483034</td>\n",
       "      <td>  7943.976048</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013_2009_Total</th>\n",
       "      <td>   NaN</td>\n",
       "      <td>  NaN</td>\n",
       "      <td>  NaN</td>\n",
       "      <td>      NaN</td>\n",
       "      <td> 41828.263211</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Investment(￥)  Added GDP(￥)  ICOR  WorthlessInvt pct  \\\n",
       "2013                     28036          5727  4.90           0.471429   \n",
       "2012                     25277          5678  4.45           0.417978   \n",
       "2011                     22834          6980  3.27           0.207951   \n",
       "2010                     19360          5404  3.58           0.276536   \n",
       "2009                     16446          3280  5.01           0.483034   \n",
       "2013_2009_Total            NaN           NaN   NaN                NaN   \n",
       "\n",
       "                 WorthlessInvt  \n",
       "2013              13216.971429  \n",
       "2012              10565.217978  \n",
       "2011               4748.354740  \n",
       "2010               5353.743017  \n",
       "2009               7943.976048  \n",
       "2013_2009_Total   41828.263211  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "worthlessInvt(2009, 2013, 2.59)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are two major, indeed fatal, flaws in this. First, why have they chosen 1979-96 as their baseline for ICOR efficiency in China? A quick glance at the tables above reveals that there was a big jump in ICOR (that is, a big decline in efficiency) from 1997-2000, followed by an improvement. The 1979-96 selection leads to a sharp downward bias in their baseline estimate. If we break the ICOR into decades, and break out the past five years separately, the results are very different, as this table shows.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Investment(￥)</th>\n",
       "      <th>Added GDP(￥)</th>\n",
       "      <th>ICOR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1989_1980_Average</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td> 2.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999_1990_Average</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td> 3.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008_2000_Average</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td> 3.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013_2009_Average</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td> 4.24</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Investment(￥)  Added GDP(￥)  ICOR\n",
       "1989_1980_Average            NaN           NaN  2.81\n",
       "1999_1990_Average            NaN           NaN  3.32\n",
       "2008_2000_Average            NaN           NaN  3.29\n",
       "2013_2009_Average            NaN           NaN  4.24"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_icor = pd.concat(icor_average(*x).tail(1) for x in [(1980,1989),(1990,1999),(2000,2008),(2009,2013)])\n",
    "new_icor"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using Mr Xu and Ms Wang’s method for calculating efficiency differences, we now can compare the ICOR of 4.2 over the past five years with 3.3, the average for both of the previous two decades. This is a much more relevant yardstick than the pre-1997 era. On this revised basis, China’s investments after the global financial were 21% less efficient than in the 1990-2008 period. Sticking to Mr Xu and Ms Wang’s approach, this would mean that 21% of all investment over the past five years – 22.6 trillion yuan (`$3.7` trillion) – had been wasted. That is still a lot of money to burn through, but it is almost half their headline-grabbing estimate."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Investment(￥)</th>\n",
       "      <th>Added GDP(￥)</th>\n",
       "      <th>ICOR</th>\n",
       "      <th>WorthlessInvt pct</th>\n",
       "      <th>WorthlessInvt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013</th>\n",
       "      <td> 28036</td>\n",
       "      <td> 5727</td>\n",
       "      <td> 4.90</td>\n",
       "      <td> 0.326531</td>\n",
       "      <td>  9154.612245</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012</th>\n",
       "      <td> 25277</td>\n",
       "      <td> 5678</td>\n",
       "      <td> 4.45</td>\n",
       "      <td> 0.258427</td>\n",
       "      <td>  6532.258427</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2011</th>\n",
       "      <td> 22834</td>\n",
       "      <td> 6980</td>\n",
       "      <td> 3.27</td>\n",
       "      <td>-0.009174</td>\n",
       "      <td>  -209.486239</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td> 19360</td>\n",
       "      <td> 5404</td>\n",
       "      <td> 3.58</td>\n",
       "      <td> 0.078212</td>\n",
       "      <td>  1514.189944</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td> 16446</td>\n",
       "      <td> 3280</td>\n",
       "      <td> 5.01</td>\n",
       "      <td> 0.341317</td>\n",
       "      <td>  5613.305389</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013_2009_Total</th>\n",
       "      <td>   NaN</td>\n",
       "      <td>  NaN</td>\n",
       "      <td>  NaN</td>\n",
       "      <td>      NaN</td>\n",
       "      <td> 22604.879767</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Investment(￥)  Added GDP(￥)  ICOR  WorthlessInvt pct  \\\n",
       "2013                     28036          5727  4.90           0.326531   \n",
       "2012                     25277          5678  4.45           0.258427   \n",
       "2011                     22834          6980  3.27          -0.009174   \n",
       "2010                     19360          5404  3.58           0.078212   \n",
       "2009                     16446          3280  5.01           0.341317   \n",
       "2013_2009_Total            NaN           NaN   NaN                NaN   \n",
       "\n",
       "                 WorthlessInvt  \n",
       "2013               9154.612245  \n",
       "2012               6532.258427  \n",
       "2011               -209.486239  \n",
       "2010               1514.189944  \n",
       "2009               5613.305389  \n",
       "2013_2009_Total   22604.879767  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "worthlessInvt(2009, 2013, 3.3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "That leads to the second and even bigger flaw – namely, this is a lousy method for calculating wasted investment. ICOR serves as a rough guide to the efficiency of investment. It does not, however, show how much money was been wasted, only that it is generating smaller or bigger growth returns compared with previous years. For example, say that an investment of `$1000` boosts GDP by `$500` this year, but only by `$400` next year. In this case, ICOR will have risen from 2 to 2.5. Using Mr Xu and Ms Wang’s framework, because investment is 20% less efficient in the second year than it was in the first year (ICOR of 2.5 vs 2), this is tantamount to 20% of investment, or `$200`, being worthless. But that is completely absurd. All we can conclude is that the return on investment has fallen, not that `$200` has been wasted. Moreover, it is inevitable that in years when investment soars – which was, after all, the point of China’s stimulus package – investment returns will appear to suffer. The real question is whether those investments deliver returns over time, hence the point in looking at average ICORs over a longer period."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "None of this is to give the Chinese economy a clean bill of health. As we have written, [debt](http://www.economist.com/news/leaders/21625785-its-debt-will-not-drag-down-world-economy-it-risks-zombifying-countrys-financial) has increased too quickly, and declines in both productivity and investment efficiency are [worrisome](http://www.economist.com/news/finance-and-economics/21623708-weakening-productivity-casting-doubt-sustainability-chinas). But `$6.8` trillion down the drain in just five years? This at least is one thing that will not keep us up at night."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
